<template>
   <div style="background-color: #fff;">
       <headNav title="设置密码" :isBack="false" :isHome="false"></headNav>
       <div class="setPass">设置密码</div>
       <div class="inputClass">
           <input type="passWord" v-model.trim="passWord" placeholder="请设置密码">
           <input type="passWord" v-model.trim="aginPass" placeholder="请确认密码">
       </div>
       <div class="messge">设置密码要求英文+数字组合，长度为6-20</div>
       <div class="loginUp" @click="setPass">提交</div>
   </div>
</template>
<script>
import headNav from '@/components/headNav/headNav'
import {modifyPassword} from '@/api/setPassWordApi'
import cookie from '@/util/cookie'
export default {
    components:{
        headNav
    },
    data() {
        return {
            passWord:'',
            aginPass:''
        }
    },
    mounted() {
        // this.setPass()
    },
    methods: {
        setPass(){
           if(!this.passWord){
               this.$vux.toast.text('请输入密码', 'top')
               return
           }
           if(!this.aginPass){
               this.$vux.toast.text('请再次确认密码', 'top')
               return
           }
           if(this.passWord != this.aginPass){
               this.$vux.toast.text('两次输入的密码不一样', 'top')
               return
           }
            var params ={
            //    oldPwd:'',
            //    newPwd: this.aginPass,
            //    mark:'RegainPassword',
            //    loginNameMark: cookie.get('loginName')
               pwd: this.passWord,
               repeatPwd: this.aginPass
            }
            modifyPassword(params).then((res) => {
                  // 添加孩子
                if(localStorage.getItem("role") == 'parent'){
                    if(localStorage.getItem("localQRCode")){
                        this.$router.push('/myNew/addChildren')
                    }else{
                        this.$router.push('/myNew/mode')
                    }
                    return
                }
                //    创建班级
                if(localStorage.getItem("role") == 'teacher'){
                    if(localStorage.getItem("localQRCode")){
                        this.$router.push('/myNew/joinClass')
                    }else{
                        this.$router.push('/myNew/establish')
                    }
                    return
                }

                if(cookie.get('roleCode')){
                    this.$router.push('/menu/index')
                    return
                }


                 this.$router.push('/signUp/selectChoice')
            })
        }
    }
}
</script>
<style scoped>
.setPass{
    font-size: 0.48rem;
    color: #222222;
    margin: 0.72rem 0.45rem;
    margin-bottom: 0.3rem;
}
.inputClass{
    width: 6.3rem;
    margin: 0 auto;
}
.inputClass input{
    width: 97%;
    font-size: 0.32rem;
    border: none;
    border-bottom: 1px solid #E5E5E5;
    line-height: 1.12rem;
    padding-left: 0.2rem;
}
.loginUp{
    width: 5.60rem;
    height: 0.84rem;
    line-height: 0.84rem;
    text-align: center;
    color: #FFFFFF;
    font-size: 0.32rem;
    background: #128FEF;
    border-radius: 0.42rem;
    margin: 0 auto;
    margin-top: 0.46rem;
}
.messge{
    font-size: 0.24rem;
    color: #999;
    width: 6rem;
    margin: 0 auto;
    margin-top: 0.2rem;
}
</style>